

************************************************************************************************;

/* 						 This file reproduce Table 9: Investing Universe						*/

*************************************************************************************************;

libname rep "C:\Users\~";

data ls; set rep.mydata; run;

*** Panel A: Summary statistics ;

** Pooled sample ;

proc means data = ls N mean median std; var avgwgt; 
output out = bm mean(avgwgt) = meanwgt median(avgwgt) = medwgt; run;

data _null_; set bm;
call symput("lsavg", meanwgt);
call symput("lsmed", medwgt);
run;

%put &lsavg and &lsmed;

*** Constrained vs Unconstrained funds ;

proc means data = ls N mean median std; class lev;
var avgwgt; run;

*** Absolute difference between constrained vs unconstrained ;

proc sql;
create table lswide as select a.*, b.avgwgt as avgwgt_lev, b.avgrwgt as avgrwgt_lev
from ls (where =(lev =0)) as a, ls (where =(lev =1)) as b
where a.permno = b.permno and a.rdate = b.rdate; quit;

data lswide; set lswide;
abdiff = abs(avgwgt_lev - avgwgt); run;

proc means data = lswide N mean median std; 
var abdiff ; run;


*** Panel B: Hypothesis Testing ;

*** Sign test and signed rank test;

proc univariate data=lswide mu0=&lsmed; var abdiff;
ods select TestsForLocation; run;

*** t test with standard error clustered at firm level;

data ttest; set lswide; 
abdiff_mavg = abdiff - &lsavg; run;

proc genmod data = ttest; class permno;
model abdiff_mavg = ;
repeated subject=permno / type=ind; run;
quit;




